#!/bin/bash
#
# This script will generate SWF2K5-tests.cs.target from our System.Windows.Forms.dll.sources
#
#

exec > SWF2k5-tests.csproj

Source=System.Windows.Forms_test.dll.sources  
Resource=System.Windows.Forms.dll.resources

SWFhead()
{
    cat <<EOF
﻿<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <ProjectType>Local</ProjectType>
    <ProductVersion>8.0.50727</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{5E6430B2-6B9F-4E76-802E-20207EF80391}</ProjectGuid>
    <Configuration Condition=" '\$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '\$(Platform)' == '' ">AnyCPU</Platform>
    <ApplicationIcon>
    </ApplicationIcon>
    <AssemblyKeyContainerName>
    </AssemblyKeyContainerName>
    <AssemblyName>System.Windows.Forms_test</AssemblyName>
    <AssemblyOriginatorKeyFile>
    </AssemblyOriginatorKeyFile>
    <DefaultClientScript>JScript</DefaultClientScript>
    <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
    <DefaultTargetSchema>IE50</DefaultTargetSchema>
    <DelaySign>false</DelaySign>
    <OutputType>Library</OutputType>
    <RootNamespace>
    </RootNamespace>
    <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
    <StartupObject>
    </StartupObject>
    <FileUpgradeFlags>
    </FileUpgradeFlags>
    <UpgradeBackupLocation>
    </UpgradeBackupLocation>
  </PropertyGroup>
  <PropertyGroup Condition=" '\$(Configuration)|\$(Platform)' == 'Debug|AnyCPU' ">
    <OutputPath>bin\Debug\</OutputPath>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <BaseAddress>285212672</BaseAddress>
    <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
    <ConfigurationOverrideFile>
    </ConfigurationOverrideFile>
    <DefineConstants>NET_1_1 ONLY_1_1 __MonoCS__ DEBUG</DefineConstants>
    <DocumentationFile>
    </DocumentationFile>
    <DebugSymbols>true</DebugSymbols>
    <FileAlignment>4096</FileAlignment>
    <NoStdLib>false</NoStdLib>
    <NoWarn>
    </NoWarn>
    <Optimize>false</Optimize>
    <RegisterForComInterop>false</RegisterForComInterop>
    <RemoveIntegerChecks>false</RemoveIntegerChecks>
    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
    <WarningLevel>3</WarningLevel>
    <DebugType>full</DebugType>
    <ErrorReport>prompt</ErrorReport>
  </PropertyGroup>
  <PropertyGroup Condition=" '\$(Configuration)|\$(Platform)' == 'Debug 2.0|AnyCPU' ">
    <OutputPath>bin\Debug\</OutputPath>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <BaseAddress>285212672</BaseAddress>
    <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
    <ConfigurationOverrideFile>
    </ConfigurationOverrideFile>
    <DefineConstants>NET_2_0 __MonoCS__ DEBUG</DefineConstants>
    <DocumentationFile>
    </DocumentationFile>
    <DebugSymbols>true</DebugSymbols>
    <FileAlignment>4096</FileAlignment>
    <NoStdLib>false</NoStdLib>
    <NoWarn>
    </NoWarn>
    <Optimize>false</Optimize>
    <RegisterForComInterop>false</RegisterForComInterop>
    <RemoveIntegerChecks>false</RemoveIntegerChecks>
    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
    <WarningLevel>3</WarningLevel>
    <DebugType>full</DebugType>
    <ErrorReport>prompt</ErrorReport>
  </PropertyGroup>
  <PropertyGroup Condition=" '\$(Configuration)|\$(Platform)' == 'Release|AnyCPU' ">
    <OutputPath>bin\Release\</OutputPath>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <BaseAddress>285212672</BaseAddress>
    <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
    <ConfigurationOverrideFile>
    </ConfigurationOverrideFile>
    <DefineConstants>NET_1_1 ONLY_1_1 __MonoCS__</DefineConstants>
    <DocumentationFile>
    </DocumentationFile>
    <DebugSymbols>false</DebugSymbols>
    <FileAlignment>4096</FileAlignment>
    <NoStdLib>false</NoStdLib>
    <NoWarn>
    </NoWarn>
    <Optimize>false</Optimize>
    <RegisterForComInterop>false</RegisterForComInterop>
    <RemoveIntegerChecks>false</RemoveIntegerChecks>
    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
    <WarningLevel>3</WarningLevel>
    <DebugType>none</DebugType>
    <ErrorReport>prompt</ErrorReport>
  </PropertyGroup>
  <PropertyGroup Condition=" '\$(Configuration)|\$(Platform)' == 'Release 2.0|AnyCPU' ">
    <OutputPath>bin\Release\</OutputPath>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <BaseAddress>285212672</BaseAddress>
    <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
    <ConfigurationOverrideFile>
    </ConfigurationOverrideFile>
    <DefineConstants>NET_2_0 __MonoCS__</DefineConstants>
    <DocumentationFile>
    </DocumentationFile>
    <DebugSymbols>false</DebugSymbols>
    <FileAlignment>4096</FileAlignment>
    <NoStdLib>false</NoStdLib>
    <NoWarn>
    </NoWarn>
    <Optimize>false</Optimize>
    <RegisterForComInterop>false</RegisterForComInterop>
    <RemoveIntegerChecks>false</RemoveIntegerChecks>
    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
    <WarningLevel>3</WarningLevel>
    <DebugType>none</DebugType>
    <ErrorReport>prompt</ErrorReport>
  </PropertyGroup>
  <PropertyGroup Condition=" '\$(Configuration)|\$(Platform)' == 'net_2_0|AnyCPU' ">
    <OutputPath>.\</OutputPath>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <BaseAddress>285212672</BaseAddress>
    <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
    <ConfigurationOverrideFile>
    </ConfigurationOverrideFile>
    <DefineConstants>NET_1_1 NET_2_0 __MonoCS__ DEBUG</DefineConstants>
    <DocumentationFile>
    </DocumentationFile>
    <DebugSymbols>true</DebugSymbols>
    <FileAlignment>4096</FileAlignment>
    <NoStdLib>false</NoStdLib>
    <NoWarn>
    </NoWarn>
    <Optimize>false</Optimize>
    <RegisterForComInterop>false</RegisterForComInterop>
    <RemoveIntegerChecks>false</RemoveIntegerChecks>
    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
    <WarningLevel>3</WarningLevel>
    <DebugType>full</DebugType>
    <ErrorReport>prompt</ErrorReport>
    <AssemblyName>System.Windows.Forms_test_net_2_0</AssemblyName>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="nunit.framework, Version=2.2.0.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>C:\winforms-unittests\nunit.framework.dll</HintPath>
    </Reference>
    <Reference Include="Accessibility">
      <Name>Accessibility</Name>
    </Reference>
    <Reference Include="System">
      <Name>System</Name>
    </Reference>
    <Reference Include="System.Data">
      <Name>System.Data</Name>
    </Reference>
    <Reference Include="System.Data">
      <Name>System.Data</Name>
    </Reference>
    <Reference Include="System.Drawing">
      <Name>System.Drawing</Name>
    </Reference>
    <Reference Include="System.Windows.Forms">
      <Name>System.Windows.Forms</Name>
    </Reference>
    <Reference Include="System.Xml">
      <Name>System.Xml</Name>
    </Reference>
  </ItemGroup>
EOF
}

SWFtail()
{
    cat <<EOF
  <ItemGroup>
    <None Include="Test\System.Windows.Forms\ChangeLog" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Test\System.Resources\ChangeLog" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Test\System.Windows.Forms.Layout\ChangeLog" />
  </ItemGroup>
  <Import Project="\$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <PropertyGroup>
    <PreBuildEvent>
    </PreBuildEvent>
    <PostBuildEvent>
    </PostBuildEvent>
  </PropertyGroup>
</Project>
EOF
}

SWFfilelist()
{
echo "  <ItemGroup>"
cat $Source | while read SRC; do
# Don't do AssemblyInfo, it's got signing requests and such that we don't want
if [ "x$SRC" != "xAssembly/AssemblyInfo.cs" ] ; then
SRC=`echo Test/$SRC`
SRC=`echo $SRC | sed 's/Test\/..\/..\/..\/build\///'`
SRC=`echo $SRC | tr '/' '\\\\'`
cat <<EOF
    <Compile Include="$SRC" />
EOF
fi
done
echo "  </ItemGroup>"
}

SWFresourcelist()
{
echo "  <ItemGroup>"
    cat $Resource | while read SRC; do
	CUSTOMTOOLNAMESPACE=""

	# strip out that -resource:
	SRC=`echo $SRC | sed 's/-resource://'`

	CUSTOMTOOLNAMESPACE=`echo $SRC | awk -F, '{print $2}'`

	INCLUDE=`echo $SRC | awk -F, '{print $1}'`

	if test -f $INCLUDE.prebuilt; then
	    INCLUDE=$INCLUDE.prebuilt
	fi

	# strip off the path from the name of the resource and the .prebuilt if there is one
	LOGICALNAME=`echo $INCLUDE | sed 's/resources\///;s/.prebuilt//'`

	# convert all /'s to \\'s
	INCLUDE=`echo $INCLUDE | sed 's/\//\\\\/'`

	echo "    <EmbeddedResource Include=\"$INCLUDE\">"
	echo "      <LogicalName>$LOGICALNAME</LogicalName>"
	if test "x$CUSTOMTOOLNAMESPACE" != "x"; then
	    echo "      <CustomToolNameSpace>$CUSTOMTOOLNAMESPACE</CustomToolNameSpace>"
	fi
	echo "    </EmbeddedResource>"
    done
echo "  </ItemGroup>"
}

SWFhead
SWFfilelist
#SWFresourcelist
SWFtail
